import {createRouter, createWebHistory} from 'vue-router';
//import {useAuthorizationStore} from "./stores/Authorization";
import MainLayout from "./layouts/MainLayout.vue";

const routes = [
    {
        path: "",
        name: "main",
        component: MainLayout,
        children: [
            {
                path: '',
                name: 'Home',
                meta: {title: "首页 - 西建大 iOS Club"},
                component: () => import('./pages/Home.vue'),
            },
        ]
    },
];

const router = createRouter({
    history: createWebHistory(),
    routes,
});

// Navigation guard
router.beforeEach((to, _from, next) => {
    //const authorizationStore = useAuthorizationStore();

    // Set page title
    document.title = (to.meta.title as string) || "西建大 iOS Club";

    // Check if route requires authentication
    // if (to.meta.requiresAuth && !authorizationStore.isAuthenticated) {
    //     next('/login');
    // } else {
    //     next();
    // }

    next();
});

export default router;